home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 May: Tool Chest / Dev.CD May 00 TC.toast / pc / tool chest / development kits / mpw related / dts mpw goodies / addheader < prev    next >
Encoding:
Text File  |  1990-09-14  |  7.1 KB  |  252 lines

  1. #******************************************************************************
  2. #*
  3. #*  Project Name:    UserScripts
  4. #*     File Name:    AddHeader
  5. #*        Author:    Glenn L. Austin
  6. #*          Date:    June 28, 1989
  7. #*
  8. #*   Description:    Adds a header, or gets a new header
  9. #*
  10. #******************************************************************************
  11. #*                       A U T H O R   I D E N T I T Y
  12. #******************************************************************************
  13. #*
  14. #*    Initials    Name
  15. #*    --------    -----------------------------------------------
  16. #*    GLA            Glenn L. Austin
  17. #*
  18. #******************************************************************************
  19. #*                      R E V I S I O N   H I S T O R Y
  20. #******************************************************************************
  21. #*
  22. #*      Date        Time    Author    Description
  23. #*    --------    -----    ------    ---------------------------------------------
  24. ##    07/10/89    12:02    GLA        Uses a tempfile to speed up (by about an
  25. ##                                order of magnitude) creation of a new header,
  26. ##                                since it never has to redraw the window until
  27. ##                                the entire header has been built and
  28. ##                                inserted.
  29. ##    07/05/89    08:55    GLA        Revised test for passed filename to test for
  30. ##                                an empty parameter.  Also revised code to
  31. ##                                accept cancel as a valid escape from the
  32. ##                                program.
  33. ##    07/04/89    13:30    GLA        Added author identification section to the
  34. ##                                header information.
  35. #*    06/28/89    ??:??    GLA        Original version
  36. #*
  37. #******************************************************************************
  38.  
  39. set echo 0
  40.  
  41. if "{1} " == " "
  42.     set theFile "{Active}"
  43. else
  44.     set theFile    "{1}"
  45. end
  46.  
  47. ( evaluate "{theFile}" =~ /≈:([A-Za-z0-9 ]+)®3:(≈.([A-Za-z]*)®1)®2/ ) ∑ Dev:Null
  48. set theType "{®1}"
  49. set projName "{®3}"
  50. set fileName "{®2}"
  51. unset ®1 ®2 ®3
  52. if "{projName} " == " "
  53.     ( evaluate "{theFile}" =~ /≈:([A-Za-z0-9 ]+)®3:([A-Za-z0-9 ]+)®2/ ) ∑ Dev:Null
  54.     set projName "{®3}"
  55.     set fileName "{®2}"
  56.     unset ®2 ®3
  57. end
  58.  
  59. if "{theType}" =~ /[chr]/
  60.     set cmntSt    '/*'
  61.     set cmntEn    '*/'
  62.     set cmntLin    '**'
  63. else if "{theType}" == "p"
  64.     set cmntSt    '{*'
  65.     set cmntEn    '*}'
  66.     set cmntLin    '**'
  67. else if "{theType}" == "a"
  68.     set cmntSt    ';*'
  69.     set cmntEn    '**'
  70.     set cmntLin    ';*'
  71. else if "{theType}" == "cp"
  72.     set cmntSt    '//'
  73.     set cmntEn    '**'
  74.     set cmntLin    '//'
  75. else
  76.     set cmntSt    '##'
  77.     set cmntEn    '**'
  78.     set cmntLin    '##'
  79. end
  80.  
  81. ( evaluate `date -d -s` =~ /([0-9]+)®1∂/([0-9]+)®2∂/([0-9]+)®3/ ) ∑ Dev:Null
  82. set m {®1}
  83. set d {®2}
  84. set y {®3}
  85. unset ®1 ®2 ®3
  86. if {m} < 10
  87.     set m "0{m}"
  88. end
  89. if {d} < 10
  90.     set d "0{d}"
  91. end
  92. set dat "{m}∂/{d}∂/{y}"
  93. unset m d y
  94.  
  95. ( evaluate "`date -t`" =~ /([0-9]+)®1∂:([0-9]+)®2∂:([0-9]+)®3 (?)®4?*/ ) > Dev:Null
  96. if "{®4}" == "P"
  97.     if {®1} != 12
  98.         ( evaluate h = {®1} + 12 ) ∑ Dev:Null
  99.     else
  100.         set h {®1}
  101.     end
  102. else
  103.     if {®1} == 12
  104.         set h 0
  105.     else
  106.         set h {®1}
  107.     end
  108. end
  109. set m {®2}
  110. unset ®1 ®2 ®3 ®4
  111. if {h} < 10
  112.     set h "0{h}"
  113. end
  114. set tim "{h}:{m}"
  115. unset h m
  116.  
  117. if "{user} " == " "
  118.     set Initials "Unk"
  119.     set userName "Unknown author"
  120. else
  121.     set Initials ""
  122.     for f in {user}
  123.         ( evaluate "{f}" =~ /(?)®1?*/ ) > Dev:Null
  124.         set Initials "{Initials}{®1}"
  125.         unset ®1
  126.     end
  127.     set userName "{user}"
  128.     unset ®1 ®2 ®3 ®4
  129. end
  130.  
  131. mark § "===TEMP===" "{theFile}"
  132. find • "{theFile}"
  133.  
  134. set exit 0
  135.  
  136. find /∂t--------∂t-----∂t------∂t---------------------------------------------∂n/Δ "{theFile}"
  137. if {status} != 0
  138.     set descr "`request -d "What it does..." "Enter the description of ∂"{fileName}∂""`"
  139.     if "{descr} " == " "
  140.         set exit 1
  141.         
  142.         find "===TEMP===" "{theFile}"
  143.         unmark "===TEMP===" "{theFile}"
  144.  
  145.         exit 1
  146.     end
  147.     set description ""
  148.     loop
  149.         ( evaluate "{descr}" =~ /(?«45,55»)®1(?*)®2/ ) >Dev:Null
  150.         if "{®2} " == " "
  151.             unset ®1 ®2
  152.             if "{description} " != " "
  153.                 set description "{description}∂n{cmntLin}∂t∂t∂t∂t∂t{descr}"
  154.             else
  155.                 set description "{descr}"
  156.             end
  157.             break
  158.         end
  159.         unset ®1 ®2
  160.         ( evaluate "{descr}" =~ /(?«45,55»)®1 (?*)®2/ ) > Dev:Null
  161.         if "{description} " != " "
  162.             set description "{description}∂n{cmntLin}∂t∂t∂t∂t∂t{®1}"
  163.         else
  164.             set description "{®1}"
  165.         end
  166.         set descr "{®2}"
  167.         unset ®1 ®2
  168.         if "{descr} " == " "
  169.             break
  170.         end
  171.     end
  172.     unset descr
  173.     find • "{theFile}"
  174.     echo "{cmntSt}"'*****************************************************************************' >"{MPW}tempFile"
  175.     echo "{cmntLin}" >>"{MPW}tempFile"
  176.     echo "{cmntLin}"'  Project Name:'"∂t{projName}" >>"{MPW}tempFile"
  177.     echo "{cmntLin}"'     File Name:'"∂t{fileName}" >>"{MPW}tempFile"
  178.     echo "{cmntLin}" >>"{MPW}tempFile"
  179.     echo "{cmntLin}"'   Description:'"∂t{description}" >>"{MPW}tempFile"
  180.     echo "{cmntLin}" >>"{MPW}tempFile"
  181.     echo "{cmntLin}*****************************************************************************" >>"{MPW}tempFile"
  182.     echo "{cmntLin}                       A U T H O R   I D E N T I T Y" >>"{MPW}tempFile"
  183.     echo "{cmntLin}*****************************************************************************" >>"{MPW}tempFile"
  184.     echo "{cmntLin}" >>"{MPW}tempFile"
  185.     echo "{cmntLin}∂tInitials∂tName" >>"{MPW}tempFile"
  186.     echo "{cmntLin}∂t--------∂t-----------------------------------------------" >>"{MPW}tempFile"
  187.     echo "{cmntLin}∂t{Initials}∂t∂t∂t{userName}" >>"{MPW}tempFile"
  188.     echo "{cmntLin}" >>"{MPW}tempFile"
  189.     echo "{cmntLin}"'*****************************************************************************' >>"{MPW}tempFile"
  190.     echo "{cmntLin}"'                      R E V I S I O N   H I S T O R Y' >>"{MPW}tempFile"
  191.     echo "{cmntLin}"'*****************************************************************************' >>"{MPW}tempFile"
  192.     echo "{cmntLin}" >>"{MPW}tempFile"
  193.     echo "{cmntLin}∂t  Date∂t∂tTime∂tAuthor∂tDescription" >>"{MPW}tempFile"
  194.     echo "{cmntLin}∂t--------∂t-----∂t------∂t---------------------------------------------" >>"{MPW}tempFile"
  195.     echo "{cmntLin}∂t{dat}∂t{tim}∂t{Initials}∂t∂tOriginal version" >>"{MPW}tempFile"
  196.     echo "{cmntLin}" >>"{MPW}tempFile"
  197.     echo "{cmntLin}"'***************************************************************************'"{cmntEn}" >>"{MPW}tempFile"
  198.     echo "" >>"{MPW}tempFile"
  199.     catenate "{MPW}tempFile" >"{theFile}".§
  200.     delete "{MPW}tempFile"
  201. else
  202.     set descr "`request -d "What you are doing..." "Enter the revision info for ∂"{fileName}∂""`"
  203.     if "{descr} " == " "
  204.         set exit 1
  205.         
  206.         find "===TEMP===" "{theFile}"
  207.         unmark "===TEMP===" "{theFile}"
  208.  
  209.         exit 1
  210.     end
  211.     set description ""
  212.     loop
  213.         ( evaluate "{descr}" =~ /(?«35,45»)®1(?*)®2/ ) >Dev:Null
  214.         if "{®2} " == " "
  215.             unset ®1 ®2
  216.             if "{description} " != " "
  217.                 set description "{description}∂n{cmntLin}∂t∂t∂t∂t∂t∂t∂t∂t{descr}"
  218.             else
  219.                 set description "{descr}"
  220.             end
  221.             break
  222.         end
  223.         unset ®1 ®2
  224.         ( evaluate "{descr}" =~ /(?«35,45»)®1 (?*)®2/ ) > Dev:Null
  225.         if "{description} " != " "
  226.             set description "{description}∂n{cmntLin}∂t∂t∂t∂t∂t∂t∂t∂t{®1}"
  227.         else
  228.             set description "{®1}"
  229.         end
  230.         set descr "{®2}"
  231.         unset ®1 ®2
  232.         if "{descr} " == " "
  233.             break
  234.         end
  235.     end
  236.     unset descr
  237.     echo "{cmntLin}∂t{dat}∂t{tim}∂t{Initials}∂t∂t{description}" >>"{theFile}".§
  238.     find • "{theFile}"
  239.     find /∂t{Initials}∂t∂t∂t{userName}/ "{theFile}"
  240.     if {status} != 0
  241.         find /∂t--------∂t-----------------------------------------------∂n/Δ "{theFile}"
  242.         echo "{cmntLin}∂t{Initials}∂t∂t∂t{userName}" >>"{theFile}".§
  243.     end
  244. end
  245. unset description
  246.  
  247. set exit 1
  248.  
  249. find "===TEMP===" "{theFile}"
  250. unmark "===TEMP===" "{theFile}"
  251.  
  252. exit 0